package com.kpf.springcloud.common;

import com.kpf.springcloud.utils.GeneralUtil;

/**
 * 上下文
 *
 * @author shiwen
 * @date 2021/2/28
 */
public class RequestContext {

    private static ThreadLocal<Long> userId = new ThreadLocal<>();

    public static Long getUserId() {
        Long org = userId.get();
        return GeneralUtil.isObjNotNull(org) ? userId.get() : 0L;
    }

    public static void setUserId(Long liteUserId) {
        userId.set(liteUserId);
    }

    public static void removeUserId() {
        userId.remove();
    }

}